<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center changePwdOldCode_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub changePwdOldCode_fd0_0'>
				<view class='flex flex-wrap align-center'>
					<person></person>
				</view>
				<view class='flex flex-wrap align-stretch justify-center flex-sub'>
					<text class='changePwdOldCode_fd0_0_c1_c0'>修改密码</text>
				</view>
				<view class='flex flex-wrap align-center changePwdOldCode_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

		<view class="flex flex-direction flex-wrap align-stretch changePwdOldCode_flex_1">
			<view style="padding: 8rpx 0;">
				<back></back>
			</view>
			<view class='flex flex-wrap align-center changePwdOldCode_fd1_0'>
				<text class='changePwdOldCode_fd1_0_c0'>旧密码</text>
				<input class='flex-sub changePwdOldCode_fd1_0_c1' type="text" :focus='true' placeholder="请输入旧密码"
					confirm-type="done" :maxlength="12" :password='true'
					placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="oldPwd" />
			</view>
			<view class='flex flex-wrap align-center changePwdOldCode_fd1_0'>
				<text class='changePwdOldCode_fd1_0_c0'>新密码</text>
				<input class='flex-sub changePwdOldCode_fd1_0_c1' type="text" placeholder="请输入新密码（6~12位字母+数字）"
					confirm-type="done" :maxlength="12" :password='true'
					placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="newPwd" />
			</view>
			<view class='flex flex-wrap align-center changePwdOldCode_fd1_2'>
				<text class='changePwdOldCode_fd1_0_c0'>确认新密码</text>
				<input class='flex-sub changePwdOldCode_fd1_0_c1' type="text" placeholder="请确认新密码（6~12位字母+数字）"
					confirm-type="done" :maxlength="12" :password='true'
					placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="qrPwd" />
			</view>
		</view>


		<view class="flex benben-position-layout flex flex-wrap align-center changePwdOldCode_flex_2">
			<button class='changePwdOldCode_fd2_0' @tap.stop="changePwdOldCodeFunc()">完成</button>

		</view>
		<view :style="{height: '88rpx'}"></view>


	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	import back from "@/components/back/index.vue"
	import person from "@/components/person/index.vue"
	export default {
		components: {
			back,
			person
		},


		data() {
			return {
				"oldPwd": "",
				"newPwd": "",
				"qrPwd": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			handle() {
				uni.navigateTo({
					url: '/pages/xtsz/changePwd/changePwd'
				})
			},
			//改密-旧密码验证
			async changePwdOldCodeFunc() {
				if (!validate(this.oldPwd, 'require')) {
					this.$message.info('请输入旧密码');
					return false;
				}
				if (!validate(this.oldPwd, 'password')) {
					this.$message.info('请输入密码（6~12位字母+数字）');
					return false;
				}
				if (!validate(this.newPwd, 'require')) {
					this.$message.info('请输入新密码');
					return false;
				}
				if (!validate(this.newPwd, 'password')) {
					this.$message.info('请输入新密码（6~12位字母+数字）');
					return false;
				}
				if (!validate(this.qrPwd, 'require')) {
					this.$message.info('请输入确认密码');
					return false;
				}
				if (!validate(this.qrPwd, 'password')) {
					this.$message.info('请输入确认密码（6~12位字母+数字）');
					return false;
				}
				if (this.oldPwd == this.newPwd) {
					this.$message.info('旧密码和新密码不能相同');
					return false;
				}
				if (!(this.newPwd == this.qrPwd)) {
					this.$message.info('两次输入密码不一致');
					return false;
				}
				let res = await this.$api.post(global.apiUrls.a64367170444d4, {
					security_code: this.oldPwd,
					password: this.newPwd,
					password_code: this.qrPwd
				})
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}

				this.$message.info(res.data.msg);
				setTimeout(() => {
					this.logOutFunc()
				}, 800)
			},
			logOutFunc() {
				this.$store.commit('logout')
				uni.reLaunch({
					url: '/pages/tabBar/login/login'
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto !important;
	}

	.changePwdOldCode_flex_0 {
		// border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.changePwdOldCode_fd0_0_c2 {
		width: 32rpx;
		height: 32rpx;
	}

	.changePwdOldCode_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
		line-height: 88rpx;
	}

	.changePwdOldCode_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		line-height: 88rpx;
	}

	.changePwdOldCode_fd0_0 {
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.changePwdOldCode_flex_1 {
		background: #fff;
		font-size: 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.changePwdOldCode_fd1_2 {
		border-bottom: 1px solid rgba(238, 238, 238, 1);
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.changePwdOldCode_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: var(--benbenFontColor0);
	}

	.changePwdOldCode_fd1_0_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		width: 182rpx;
	}

	.changePwdOldCode_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.changePwdOldCode_flex_2 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 5;
		bottom: calc(56rpx + var(--window-bottom));
	}

	.changePwdOldCode_fd2_0 {
		background: #6A0002;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		width: 686rpx;
		height: 88rpx;
		margin: 0rpx auto 0rpx auto;
		line-height: 88rpx;
	}
</style>